<?php 
class Mods extends E_Entity 
{
	public   $table =array(
					"id" =>"id",
					"version"=>"version",
					"userid" =>"userid",  
					"siteid" =>"siteid", 
					"roomid" =>"roomid",  
					"widgetid" =>"widgetid",
					"widgetname" =>"widgetname",
					"title" =>"title",
					"setting"=>"setting",
					"sign" =>"sign",
					"status" =>"status",
					"ctime" =>"ctime",
					"mtime" =>"mtime"
					);
					
	public function getTableName()
	{
		return "micro_mod";
	}
	public function getJoinMap()
	{
		$map = array("mapBulletin" =>array("Entity"=>"Bulletins","Method"=>"getByModId", "param"=>"id"),
					 "mapForumlist" =>array("Entity"=>"Forums","Method"=>"getListByModId", "param"=>"id"),
					 "mapPhotolist" =>array("Entity"=>"Photos","Method"=>"getListByModId", "param"=>"id"),
					 "mapMessagelist" =>array("Entity"=>"Messages","Method"=>"getListByModId", "param"=>"id"),
					 "mapUser" =>array("Entity"=>"Users","Method"=>"getByid", "param"=>"userid"),
						);
		return $map;
	}	
	public static function insertEntity($row)
	{	
		$entity = new self();
	 	return $entity->createEntityForRow($row);
	}
	public static function getById($id)
	{
		$entity = new self();
		$sql =  "select * from {$entity->getTableName()} where  {$entity->table['id']} = :id";
		return $entity->getEntityByIndexKey($sql, $id, array("id"=>$id));
	}
	public static function getNum($roomid)
	{
		$entity = new self();
		$db = $entity->getDbHandle();
		
		$sql =  "select count(1) as num  from {$entity->getTableName()} where {$entity->table['roomid']} = '$roomid'";
		$row = $db->fetch($sql);
		return $row['num'];
	}
	public static function getList()
	{
		$entity = new self();
		$sql =  "select * from {$entity->getTableName()} ";
		return $entity->birthEntity($sql);
	}
}
?>